home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / vgakit52.zip / SVGAMODE.ASM < prev    next >
Assembly Source File  |  1992-10-21  |  4KB  |  218 lines

  1.  
  2.     include model.inc
  3.     include    vesa.inc
  4.  
  5. ;
  6. ;    VGAKIT Version 5.2b
  7. ;
  8. ;    Copyright 1988,89,90,91,92 John Bridges
  9. ;    Free for use in commercial, shareware or freeware applications
  10. ;
  11. ;    SVGAMODE.ASM
  12. ;
  13. ;
  14. .data
  15.     extrn    cirrus:byte,everex:byte,paradise:byte,tseng:byte,trident:byte
  16.     extrn    t8900:byte,ativga:byte,aheada:byte,aheadb:byte
  17.     extrn    oaktech:byte,video7:byte,chipstech:byte,tseng4:byte,genoa:byte
  18.     extrn    ncr:byte,compaq:byte,acumos:byte,vesa:byte
  19.  
  20.     extrn    curbk:word,bksize:word
  21.  
  22.     extrn    vesafunc:dword
  23.  
  24.     public    maxx,maxy,scanline,ourseg
  25.  
  26. maxx    dw    ?        ;scanline of screen in pixels
  27. maxy    dw    ?        ;height of screen in pixels
  28. scanline dw    ?        ;actual width screen in bytes
  29. ourseg    dw    ?        ;segment of screen buffer
  30.  
  31.  
  32.     public    adrtbl
  33.  
  34. adrtbl    dd    1024 dup (?)    ;offset and bank for each scanline
  35.  
  36. .code
  37.  
  38.     public    mkadrtbl
  39.     public    svgamode
  40.     public    txtmode
  41.     public    setmany
  42.  
  43. mkadrtbl proc    uses di si
  44.     mov    di,offset adrtbl
  45.     mov    ax,ds
  46.     mov    es,ax
  47.     mov    bx,[maxy]
  48.  
  49.     mov    ax,[bksize]
  50.     cmp    ax,64
  51.     jz    nobnk
  52.     mov    cl,10
  53.     shl    ax,cl
  54.     dec    ax
  55.     mov    si,ax
  56.     mov    cl,9
  57.     mov    ax,[bksize]
  58. shlp:    inc    cl
  59.     shr    ax,1
  60.     jnz    shlp
  61.     xor    ax,ax
  62.     xor    dx,dx
  63. lp:    push    ax
  64.     shr    ax,cl
  65.     add    dx,ax
  66.     pop    ax
  67.     and    ax,si
  68.     stosw
  69.     xchg    ax,dx
  70.     stosw
  71.     xchg    ax,dx
  72.     add    ax,[scanline]
  73.     dec    bx
  74.     jnz    lp
  75.     ret
  76.  
  77. nobnk:    xor    ax,ax
  78.     xor    dx,dx
  79.     mov    si,[scanline]
  80.     mov    cx,bx
  81. nlp:    stosw
  82.     xchg    ax,dx
  83.     stosw
  84.     xchg    ax,dx
  85.     add    ax,si
  86.     adc    dx,0
  87.     loop    nlp
  88.     ret
  89.  
  90. mkadrtbl endp
  91.  
  92. svgamode proc            ;Set 640x480x256 on most SVGA cards
  93.     mov    [ourseg],0a000h
  94.     mov    ax,640
  95.     mov    [maxx],ax        ;default width to 640 for now
  96.     mov    [scanline],ax
  97.  
  98.     cmp    [vesa],0
  99.     jz    novs
  100.     mov    bx,101h
  101.     call    vesaset
  102.     jmp    godo2
  103. novs:    cmp    [compaq],0
  104.     jz    nocp
  105.     mov    [scanline],1024
  106.     mov    ax,2eh
  107.     jmp    godo
  108. nocp:    cmp    [genoa],0
  109.     jz    nogn
  110.     mov    ax,5ch
  111.     jmp    godo
  112. nogn:    cmp    [ncr],0
  113.     jz    noncr
  114.     mov    ax,5fh
  115.     jmp    godo
  116. noncr:    cmp    [oaktech],0
  117.     jz    noak
  118.     mov    ax,53h
  119.     jmp    short godo
  120. noak:    cmp    [aheada],0
  121.     jnz    @f
  122.     cmp    [aheadb],0
  123.     jz    noab
  124. @@:    mov    ax,61h
  125.     jmp    short godo
  126. noab:    cmp    [everex],0
  127.     jz    noev
  128.     mov    ax,70h
  129.     mov    bl,30h
  130.     jmp    short godo
  131. noev:    cmp    [ativga],0
  132.     jz    noati
  133.     mov    ax,62h
  134.     jmp    short godo
  135. noati:    cmp    [trident],0
  136.     jz    notr
  137.     mov    ax,5dh
  138.     jmp    short godo
  139. notr:    cmp    [video7],0
  140.     jz    nov7
  141.     mov    ax,6f05h
  142.     mov    bl,67h
  143.     jmp    short godo
  144. nov7:    cmp    [chipstech],0
  145.     jz    noct
  146.     mov    ax,79h
  147.     jmp    short godo
  148. noct:    cmp    [acumos],0
  149.     jnz    dopd
  150.     cmp    [paradise],0
  151.     jz    nopd
  152. dopd:    mov    ax,5fh
  153.     jmp    short godo
  154. nopd:    cmp    [tseng],0
  155.     jz    nots
  156.     mov    ax,2eh
  157. godo:    int    10h
  158.  
  159. godo2:    mov    [curbk],-1
  160.     mov    ax,40h
  161.     mov    es,ax
  162.     mov    al,es:[84h]        ;get height of screen
  163.     inc    al
  164.     mul    byte ptr es:[85h]
  165.     mov    [maxy],ax
  166.     call    mkadrtbl
  167. nots:    ret
  168. svgamode endp
  169.  
  170. vesaset    proc    near uses di
  171.     local    modebuf[260]:byte    ; extra large to make up for
  172.                     ; bugs in some VESA VBE's
  173.  
  174.     push    bx
  175.     mov    ax,4f02h        ; set the VESA videomode
  176.     int    10h
  177.     pop    cx
  178.     mov    ax,ss
  179.     mov    es,ax
  180.     lea    di,modebuf[0]        ; get the mode information
  181.     mov    ax,4f01h
  182.     int    10h
  183.     mov    ax,modebuf.vesamode.WinGranularity
  184.     mov    [bksize],ax        ; bank size from vesamode structure
  185.     mov    ax,modebuf.vesamode.BytesPerLine
  186.     mov    [scanline],ax        ; scan line byte width from vesamode
  187.     mov    ax,word ptr modebuf.vesamode.WinFuncPtr
  188.     mov    word ptr [vesafunc],ax
  189.     mov    ax,word ptr modebuf.vesamode.WinFuncPtr+2
  190.     mov    word ptr [vesafunc+2],ax
  191.     ret
  192. vesaset    endp
  193.  
  194. txtmode    proc
  195.     mov    ax,3
  196.     int    10h
  197.     ret
  198. txtmode    endp
  199.  
  200. setmany proc    palbuf:ptr byte,begcol:word,numcol:word
  201. if @Datasize
  202.     les    dx,[palbuf]
  203. else
  204.     mov    ax,ds
  205.     mov    es,ax
  206.     mov    dx,[palbuf]
  207. endif
  208.     mov    bx,[begcol]
  209.     mov    cx,[numcol]
  210.     mov    ax,1012h
  211.     int    10h
  212.     ret
  213. setmany endp
  214.  
  215.  
  216.     end
  217.  
  218.